<!-- Displays "Challenge XXX" or "Challenge your friends" link -->
<% match = Match.find(sid) unless local_assigns.has_key?(:match) %>
<%match_placed =  (@user||current_user).bets.map{|b| b.match_id}.include?(sid.to_i)%>
<%span_start = "<span class='show_span' style='padding-left:15px'><span class='menu_arrow' onmouseover=\"this.setStyle({color: '#666666'})\"  onmouseout=\"this.setStyle({color: '#000'})\">"%>
<%span_end = "</span></span>"%>
<!--place challenge-->
<%if match_placed%>
    <%if u and u != current_user%>
		<%=link_to span_start+"Challenge<br/>" + u.name+span_end,"#",:clicktoshowdialog=>"dialog_#{sid}_#{u.id}", :class=>'comments'%>
		<%=render :partial=>'friends_bet/place_challenge',:locals=>{:sid=>sid,:u=>u}%>
   <%elsif u and u == current_user%>
		<%=link_to span_start+"Challenge your friends"+span_end,"#", :class=>'comments', :clicktoshowdialog=>"dialog_#{sid.to_s}" if Time.now < match.begin_at %></span>
		<%=render :partial=>'friends_bet/place_challenge',:locals=>{:sid=>sid,:u=>nil}%>
   <%else%>
		<%=link_to span_start+"Challenge your friends"+span_end,"#", :class=>'comments',:clicktoshowdialog=>"dialog_#{sid.to_s + (u.nil? ? "" : "_" + u.id.to_s)}" if Time.now < match.begin_at%></span>
		<%=render :partial=>'friends_bet/place_challenge',:locals=>{:sid=>sid,:u=>u}%>
   <%end%>
<%else%>
    <%if u and u != current_user%>
       <%=link_to span_start+"Challenge<br/>" + u.name+span_end,"#", :class=>'comments',:onclick=>"showDialog('#{@call_back_url + "/friends_bet/gen_dialog?sid=" + sid.to_s + "&uid=" + u.id.to_s}');return false" if Time.now < match.begin_at%></span>
    <%elsif u and u == current_user%>
       <%=link_to span_start+"Challenge your friends"+span_end,"#match_#{sid}", :class=>'comments',:onclick=>"showDialog('#{@call_back_url + "/friends_bet/gen_dialog?sid=" + sid.to_s}');return false" if Time.now < match.begin_at%></span>
    <%else%>
       <%=link_to span_start+"Challenge your friends"+span_end,"#match_#{sid}", :class=>'comments',:onclick=>"showDialog('#{@call_back_url + "/friends_bet/gen_dialog?sid=" + sid.to_s}');return false" if Time.now < match.begin_at%></span>
    <%end%>
<%end%>
